#!python
# -*-coding:utf-8-*-
import os, sys, re
#创建字典
d={}
with open("out.fasta",'w') as o:
   with open("D:\\zhu_development\\Gitee\\bi2021-qlnu\\Class-project\\朱慧琪\\Project-1\\test.fasta","r") as f:
      for line in f:
          line = line.strip()
          if line[0] == ">":
              id = re.split(r'\|',line)[2]
              d[id]=o.write("{}".format(id))
          else:
              o.write("\t{}\n".format(len(line))) 
print(d.items())
#将结果存入
import csv
             
with open('test.csv','w',newline='',encoding='utf-8') as f1:
    [f1.write('\"{0}\" , {1}\n'.format(key, value)) for key, value in d.items()] 
